﻿<ResourceDictionary x:Class="MyCustomWindowStyle.MacStyledWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

	<ResourceDictionary.MergedDictionaries>
		<!-- Resource Dictionary containing Buttons used for the Mac Window titlebar buttons-->
		<ResourceDictionary Source="TitleBarStyledButtons.xaml" />
	</ResourceDictionary.MergedDictionaries>

	<!-- Border defining the frame of the Window -->
	<Style x:Key="MacwindowBorder" TargetType="Border">
		<Setter Property="CornerRadius" Value="10, 10, 0, 0" />
		<Setter Property="Background" Value="#Ababab" />
		<Setter Property="BorderBrush" Value="DimGray" />
		<Setter Property="BorderThickness" Value="1" />
		<Setter Property="HorizontalAlignment" Value="Stretch" />
		<Setter Property="VerticalAlignment" Value="Stretch" />
	</Style>

	<!-- Window Template -->
	<ControlTemplate x:Key="MacWindowTemplate" TargetType="{x:Type Window}">
		<Grid>
			<Border Name="MacWindowFrame" Style="{StaticResource MacwindowBorder}">
				<Grid>
					<Grid.RowDefinitions>
						<RowDefinition Height="Auto" />
						<RowDefinition />
					</Grid.RowDefinitions>
					<!-- The title bar. -->
					<Border MouseLeftButtonDown="titleBar_MouseLeftButtonDown" Padding="15" CornerRadius="10, 10, 0, 0">
						<Border.Background>
							<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
								<GradientStop Color="#FFABABAB"/>
								<GradientStop Color="#FF202020" Offset="1"/>
							</LinearGradientBrush>
						</Border.Background>
					</Border>
					<TextBlock Foreground="White" Text="{TemplateBinding Title}" MouseLeftButtonDown="titleBar_MouseLeftButtonDown" 
                               HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Normal" />
					<StackPanel Orientation="Horizontal">
						<Button Style="{StaticResource CloseRadialButton}" Click="closeButton_Click" 
                                HorizontalAlignment="Left" VerticalAlignment="Center" 
                            Margin="10,0,0,0" />
						<Button Style="{StaticResource MinimizeRadialButton}" Click="minimizeButton_Click" 
                                HorizontalAlignment="Left" VerticalAlignment="Center" 
                            Margin="7,0,0,0" />
						<Button Style="{StaticResource MaximizeRadialButton}" Click="maximizeButton_Click" 
                                HorizontalAlignment="Left" VerticalAlignment="Center" 
                            Margin="7,0,0,0" />
					</StackPanel>
					<!-- The window content. -->
					<Border Grid.Row="1">
						<AdornerDecorator>
							<ContentPresenter />
						</AdornerDecorator>
					</Border>
				</Grid>
			</Border>
		</Grid>
	</ControlTemplate>

	<!-- Mac Window Style -->
	<Style x:Key="MacWindowStyle" TargetType="Window">
		<Setter Property="Background" Value="Transparent" />
		<Setter Property="WindowStyle" Value="None" />
		<Setter Property="AllowsTransparency" Value="True" />
		<Setter Property="Opacity" Value="0.95" />
		<Setter Property="Template" Value="{StaticResource MacWindowTemplate}" />
	</Style>

</ResourceDictionary>
